package com.qeeyou.apps.android.craftsman.adapter;

import android.app.Activity;
import android.view.LayoutInflater;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.qeeyou.apps.android.craftsman.R;
import com.qeeyou.apps.android.craftsman.po.PushMsgInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by xuchengxiong on 2017/12/17.
 */

public class SystemNoticeAdapter extends BaseQuickAdapter<PushMsgInfo, BaseViewHolder> {

    private Activity mActivity;
    private List<PushMsgInfo> noticeList;

    public SystemNoticeAdapter(Activity activity, List<PushMsgInfo> noticeList) {
        super(R.layout.view_item_system_notice, noticeList);
        mActivity = activity;
        mLayoutInflater = LayoutInflater.from(mActivity);
        if (this.noticeList == null) {
            this.noticeList = new ArrayList<PushMsgInfo>();
        }
        this.noticeList.clear();
        if (noticeList != null && noticeList.size() > 0) {
            this.noticeList.addAll(noticeList);
        }
    }

    public void setItems(List<PushMsgInfo> noticeList) {
        if (this.noticeList == null) {
            this.noticeList = new ArrayList<PushMsgInfo>();
        }
        this.noticeList.clear();
        if (noticeList != null && noticeList.size() > 0) {
            this.noticeList.addAll(noticeList);
        }
        notifyDataSetChanged();
    }

    @Override
    protected void convert(BaseViewHolder helper, PushMsgInfo item) {
        if (item != null) {
            helper.setText(R.id.txtvTitle4ItemSystemNotice, item.getTitle());
            helper.setText(R.id.txtvTime4ItemSystemNotice, item.getDate());
            helper.setText(R.id.txtvNotice4ItemSystemNotice, item.getContent());
        }
    }
}
